package com.newspublish.system.controller;

import com.newspublish.system.service.CollectService;
import com.newspublish.system.utils.result.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Api(tags = "新闻收藏管理")
@RestController
@RequestMapping("/admin/collect")
public class CollectController {

    @Autowired
    private CollectService collectService;

    @ApiOperation(value="收藏新闻")
    @GetMapping("/collectNews/{id}")
    public Result collectNews(@PathVariable("id")Long id){
        return collectService.collectNews(id);
    }

    @ApiOperation(value="取消收藏")
    @GetMapping("/cancelNews/{id}")
    public Result cancelNews(@PathVariable("id") Long id){
        return collectService.cancelNews(id);
    }

    @ApiOperation(value="获取所有收藏的新闻")
    @GetMapping("/getAllCollection")
    public Result getAllCollection(){
        return collectService.getAllCollection();
    }


}
